package industry;

import industry.IndustryBuff.Industry;

import java.util.HashMap;

import org.bukkit.block.Block;
import org.bukkit.entity.Player;

public class IndustryBuffManager {
	private static HashMap<Player, IndustryBuff> industryBuffs = new HashMap<Player, IndustryBuff>();

	public static void add(Player player, Block block, Industry industry) {
		if (industryBuffs.containsKey(player)) {
			reset(player);
		}
		industryBuffs.put(player, new IndustryBuff(player, block, industry));
	}
	
	public static void refresh(Player player, Block block, Industry industry) {
		if (industryBuffs.containsKey(player)) {
			if (industryBuffs.get(player).getIndustry().equals(industry)) {
				industryBuffs.get(player).refresh(block);
			}
		}
	}

	public static void reset(Player player) {
		if (industryBuffs.containsKey(player)) {
			industryBuffs.get(player).stop();
			industryBuffs.remove(player);
		}
	}
}
